<template>
  <button class="yghh-button" :class="[`yghh-button-${type}`,{
    'is-plain':plain,
    'is-round':round,
    'is-circle':circle
    }]" @click="handclick">
    <span>
      <slot>按钮</slot>
    </span>
  </button>
</template>

<script>
  export default {
    // name跟调用时写的标签名一致
    name: 'yghh-btn',
    props: {
      type: {
        type: String,
        default: 'default'
      },
      plain:{
        type:Boolean,
        default:false
      },
      round:{
        type:Boolean,
        default:false
      },
      circle:{
        type:Boolean,
        default:false
      },
    },
    methods:{
      handclick(e){
        this.$emit("click",e)
      }
    }
  }
</script>

<style>
  .yghh-button {
    display: inline-block;
    line-height: 1;
    white-space: nowrap;
    cursor: pointer;
    background: #ffffff;
    border: 1px solid #dcdfe6;
    color: #606266;
    -webkit-appearance: none;
    text-align: center;
    box-sizing: border-box;
    outline: none;
    margin: 0;
    transition: 0.1s;
    font-weight: 500;
    //禁止元素的文字被选中
    -moz-user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    padding: .15rem .3rem;
    border-radius: 4px;
  }

  .yghh-button:active{
    color: yellow;
    background: red;
  }

  /* btn-type */
  .yghh-button-primary {
    color: #fff;
    background-color: #409eff;
    border-color: #409eff;
  }

  .yghh-button-success {
    color: #fff;
    background-color: #67c23a;
    border-color: #67c23a;
  }

  .yghh-button-info {
    color: #fff;
    background-color: #909399;
    border-color: #909399;
  }

  .yghh-button-warning {
    color: #fff;
    background-color: #e6a23c;
    border-color: #e6a23c;
  }

  .yghh-button-danger {
    color: #fff;
    background-color: #f56c6c;
    border-color: #f56c6c;
  }


  // 朴素按钮样式
  .yghh-button-primary.is-plain {
    color: #409eff;
    background: #ecf5ff;
  }

  .yghh-button-success.is-plain {
    color: #67c23a;
    background: #c2e7b0;
  }

  .yghh-button-info.is-plain {
    color: #909399;
    background: #d3d4d6;
  }

  .yghh-button-warning.is-plain {
    color: #e6a23c;
    background: #f5dab1;
  }

  .yghh-button-danger.is-plain {
    color: #f56c6c;
    background: #fbc4c4;
  }

  /* circle-btn */
  .yghh-button.is-circle {
    border-radius: 50%;
    padding: .15rem;
  }

  .yghh-button.is-round{
    border-radius: .35rem;
    padding: .15rem .3rem;
  }

  /* icon-btn */
  [class*='one-icon'] {
    font-family: "iconfont" !important;
    font-size: .28rem;
    font-style: normal;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
  }
</style>
